#ifndef __ADAPTER_H__
#define __ADAPTER_H__

#include <iostream>

/// @brief 球员
class Player
{
protected:
    std::string m_name;
    Player(const std::string &name)
        : m_name(name)
    {
    }

public:
    virtual void Offense() = 0;
    virtual void Defense() = 0;
};
/// @brief 前锋
class Forward : public Player
{
public:
    Forward(const std::string &name)
        : Player(name)
    {
    }
    virtual void Offense() override
    {
        printf("前锋%s，进攻\n", m_name.c_str());
    }
    virtual void Defense() override
    {
        printf("前锋%s，防守\n", m_name.c_str());
    }
};
/// @brief 中锋
class Centre : public Player
{
public:
    Centre(const std::string &name)
        : Player(name)
    {
    }
    virtual void Offense() override
    {
        printf("中锋%s，进攻\n", m_name.c_str());
    }
    virtual void Defense() override
    {
        printf("中锋%s，防守\n", m_name.c_str());
    }
};
/// @brief 后卫
class Guard : public Player
{
public:
    Guard(const std::string &name)
        : Player(name)
    {
    }
    virtual void Offense() override
    {
        printf("后卫%s，进攻\n", m_name.c_str());
    }
    virtual void Defense() override
    {
        printf("后卫%s，防守\n", m_name.c_str());
    }
};
/// @brief 外籍中锋
class ForeignCenter
{
private:
    std::string m_name;

public:
    ForeignCenter(const std::string &name)
        : m_name(name)
    {
    }
    void 进攻()
    {
        printf("中锋%s，进攻\n", m_name.c_str());
    }
    void 防守()
    {
        printf("中锋%s，防守\n", m_name.c_str());
    }
};
/// @brief 翻译官（适配器）
class Adepter : public Player
{
private:
    ForeignCenter *m_player{};

public:
    Adepter(const std::string &name)
        : Player(name), m_player(new ForeignCenter(name))
    {
    }
    virtual void Offense() override
    {
        m_player->进攻();
    }
    virtual void Defense() override
    {
        m_player->防守();
    }
};

#endif